
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
%>

<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="<%=path%>/backstatic/lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="<%=path%>/backstatic/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/backstatic/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/backstatic/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/backstatic/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/backstatic/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="<%=path%>/backstatic/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>用户管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户中心 <span class="c-gray en">&gt;</span> 用户管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <ul>
            <li style="float: left;margin-left: 5px;"><span>审核状态：</span></li>
            <li style="float: left;margin-left: 5px;"><a onclick="initData(0)" class="label label-success radius" >审核通过</a></li>
            <li style="float: left;margin-left: 5px;"><a onclick="initData(1)" class="label radius">待审核</a></li>
            <li style="float: left;margin-left: 5px;"><a onclick="initData(2)" class="label label-danger radius">未通过</a></li>
            <li style="float: left;margin-left: 5px;"><a onclick="initData(null)" class="label label-default radius">全部</a></li>
        </ul>
    </div>
    <span id="checkUserData">

	</span>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="<%=path%>/backstatic/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="<%=path%>/backstatic/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="<%=path%>/backstatic/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="<%=path%>/backstatic/h-ui.admin/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="<%=path%>/backstatic/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="<%=path%>/backstatic/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<%=path%>/backstatic/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">


    $(function(){
        initData(null);//进入页面，显示全部审核状态的用户
    });

    function initData(n){
        $.get("<%=path%>/backstage/usertype/companyData",
            {userStates:n},
            function (data) {
                $("#checkUserData").html(data);
            }
        )
    }


    /*写不通过原因并且发送邮件/短信的方法*/
    function writeBanReason(userinfoid,useremail,userphone,companyName) {
        layer.open({
            title:'不通过原因',
            content: '<textarea id="banReason" placeholder="请输入企业认证不通过的原因" cols="35" rows="3" style="margin-left: auto;"></textarea>',
            btn:['发送邮件','不发送'],
            btn1:function (index) {
                var mes = $("#banReason").val();
                $.get("<%=path%>/backstage/usertype/sendEmail",
                      {userid:userinfoid,email:useremail,phone:userphone,mes:mes,companyName:companyName},
                      function() {

                     });

                layer.msg('未通过', {icon: 5, time: 1000});
                layer.close(index);
            },
            btn2:function (index) {
            },
        });
    }

    //显示公司图片
    function showCompany(obj) {
        var pic = $(obj).attr("v");
        layer.open({
            title:'公司详情',
            area:['500px', '500px'],
          /*  height:'500px',
            width:'500px',*/
            content: '<img style="width:500px;height:500px;" src="<%=path%>/static/images/'+pic+'" />',

        });
    }

    /*资讯-审核*/
    function article_shenhe(obj,id){
        layer.confirm('审核认证？', {
                btn: ['通过','不通过','取消'],
                shade: false,
                closeBtn: 0
            },
            function(){
                var id = $(obj).parent().attr("id");
                $.get("<%=path%>/backstage/usertype/changeCompanyStatus",
                    {id:id,flag:true},
                    function () {
                        $(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_stop(this,id)" href="javascript:;" title="审核通过">取消通过</a>');
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已通过</span>');
                        $(obj).remove();
                        layer.msg('已通过', {icon:6,time:1000});
                    })
            },

            function(){
                var id = $(obj).parent().attr("id");
                var useremail = $(obj).parent().attr("emailx");
                var userphone = $(obj).parent().attr("phonex");
                var companyName = $(obj).parent().attr("cn");
                $.get("<%=path%>/backstage/usertype/changeCompanyStatus",
                    {id:id,flag:false},
                    function () {
                        $(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_start(this,id)" href="javascript:;" title="审核未通过">通过</a>');
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-danger radius">未通过</span>');
                        $(obj).remove();
                        writeBanReason(id,useremail,userphone,companyName);
                        //layer.msg('未通过', {icon: 5, time: 1000});
                    })
            });
    }
    /*资讯-下架*/
    function article_stop(obj,id){
        layer.confirm('确认要取消通过吗？',function(index){
            var id = $(obj).parent().attr("id");
            var useremail = $(obj).parent().attr("emailx");
            var userphone = $(obj).parent().attr("phonex");
            var companyName = $(obj).parent().attr("cn");
            $.get("<%=path%>/backstage/usertype/changeCompanyStatus",
                {id:id,flag:false},
                function () {
                    $(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_start(this,id)" href="javascript:;" title="审核未通过">通过</a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-danger radius">已取消通过</span>');
                    $(obj).remove();
                    writeBanReason(id,useremail,userphone,companyName);
                    //layer.msg('已取消通过', {icon: 5, time: 1000});
                })
        });
    }

    /*资讯-发布*/
    function article_start(obj,id){
        layer.confirm('确认通过吗？',function(index){
            var id = $(obj).parent().attr("id");
            $.get("<%=path%>/backstage/usertype/changeCompanyStatus",
                {id:id,flag:true},
                function () {
                    $(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_stop(this,id)" href="javascript:;" title="审核通过">取消通过</a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已通过</span>');
                    $(obj).remove();
                    layer.msg('已通过', {icon: 6, time: 1000});
                })
        });
    }

</script>
</body>
</html>